﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TraCuuTinRaoVat
{
    public partial class UserControlDanhMucCon : System.Web.UI.UserControl
    {
        

        protected void Button2_Click(object sender, EventArgs e)
        {
            try
            {
                LinQ_RaoVatDataContext danhsach = new LinQ_RaoVatDataContext();
                DANH_MUC_CON dmCon = new DANH_MUC_CON();
                dmCon.MaDanhMucChinh = int.Parse(txtMaDanhMucChinh.Text);
                dmCon.TenDanhMucCon = txtTenDanhMucCon.Text;
                if (int.Parse(dropTrangThai2.SelectedValue.ToString()) == 1)
                {
                    dmCon.Deleted = true;
                }
                else
                {
                    dmCon.Deleted = false;
                }
                
                danhsach.DANH_MUC_CONs.InsertOnSubmit(dmCon);
                danhsach.SubmitChanges();
                lblResultCon.Text = "Thêm danh mục con thành công";
            }

            catch (Exception ex)
            {
                lblResultCon.Text = "Kiểm tra lại dữ liệu nhập";
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            txtMaDanhMucChinh.Text = "";
            txtTenDanhMucCon.Text = "";
        }
    }
}